package com.suoluo.zenadmin.controllers.portal;

import net.paoding.rose.web.Invocation;
import net.paoding.rose.web.annotation.Param;
import net.paoding.rose.web.annotation.Path;
import net.paoding.rose.web.annotation.rest.Get;

/**
 * 
 * 适配以前的老地址，避免被收录的地址不能访问
 * @author xiongxu
 *
 */
@Path("views")
public class ViewsController {

	/**
	 * 首页
   	 *      http://www.zentravel.cn/views/home.do?action=viewHome
	 */
	@Get("home.do")
	public String home(){
		//转发到首页
		return "c:/";
	}
	
	/**
	 * 风格偏好
  	 *	首页:http://www.zentravel.cn/views/style/styleAction.do?action=homeStyleList <br>
     *      最新:http://www.zentravel.cn/views/style/styleAction.do?action=latest&pageNum=1 <br>
     * 			最新详细:http://www.zentravel.cn/views/style/styleAction.doaction=featureItemDetail&featureItemId=821&featureCategoryId=31<br>
  	 *	目的地:http://www.zentravel.cn/views/style/styleAction.do?action=dest&pageNum=1<br>
  	 *  酒店     ：http://zentravel.cn/views/style/styleAction.do?action=hotel&pageNum=1
  	 *	新闻:http://www.zentravel.cn/views/style/styleAction.do?action=news&pageNum=1<br>
     *		新闻详细:http://www.zentravel.cn/views/style/styleAction.do?action=newsDetail&newsId=54<br>
  	 *	线路精选:http://www.zentravel.cn/views/style/styleAction.do?action=stroke&pageNum=1<br>
     *		行程特色:http://www.zentravel.cn/views/style/strokeViewsAction.do?action=strokeDetail&strokeId=15<br>
     *		日期报价:http://www.zentravel.cn/views/style/strokeViewsAction.do?action=daysPrice&strokeId=15<br>
     *		包名须知:http://www.zentravel.cn/views/style/strokeViewsAction.do?action=signupTip&strokeId=15<br>
  	 *	特别体验:http://www.zentravel.cn/views/style/styleAction.do?action=featureItem&pageNum=1&featureCategoryId=5<br>
     *	详细:http://www.zentravel.cn/views/style/styleAction.do?action=featureItemDetail&featureItemId=863&featureCategoryId=5<br>
	 */
	@Get({"style/styleAction.do"})
	public String classtify(Invocation inv,@Param("action") String action,@Param("pageNum") int pageNum){
		if ("homeStyleList".equals(action)){
			return "m:classify";
		}else if ("latest".equals(action)){
			return "m:classify?p="+pageNum;
		}else if ("featureItemDetail".equals(action)){
			//action=featureItemDetail&featureItemId=821&featureCategoryId=31
//			@Get("item/{fcid:[0-9]+}/{id:[0-9]+}")
			return "m:classify/item/"+inv.getParameter("featureCategoryId")+"/"+inv.getParameter("featureItemId");
		}else if ("dest".equals(action)){
			return "m:classify/destination?p="+pageNum;
		}else if ("news".equals(action)){
			return "m:classify/news?p="+pageNum;
		}else if ("newsDetail".equals(action)){
			return "m:classify/news/"+inv.getParameter("newsId");
		}else if ("featureItem".equals(action)){
			return "m:classify/item/"+inv.getParameter("featureCategoryId")+"?p="+pageNum;
		}else if ("hotel".equals(action)){
//			酒店     ：http://zentravel.cn/views/style/styleAction.do?action=hotel&pageNum=1
			return "m:classify/hotel?p="+pageNum;
		}
		return "c:404";
	}
	
	/**
	 * 目的地探索
     *    首页:http://www.zentravel.cn/views/dest/destination.do?action=toOverviewDest
     *    目的地:http://www.zentravel.cn/views/dest/destination.do?action=toDestViews&destId=27
     *    交通:http://www.zentravel.cn/views/dest/destination.do?action=viewDestTraffic&destId=27
     *    特别体验:http://www.zentravel.cn/views/dest/destination.do?action=viewDestFeature&featureId=25&featureCategoryId=5&destId=27
     *    美食:http://www.zentravel.cn/views/dest/destination.do?action=viewDestFeature&featureId=22&featureCategoryId=2&destId=27
     *    特色项:http://www.zentravel.cn/views/dest/destination.do?action=viewDestFeatureItem&featureItemId=384&featureId=22&destId=27
	 */
	@Get("dest/destination.do")
	public String destination(Invocation inv,@Param("action") String action,@Param("destId") int destId){
		if ("toOverviewDest".equals(action)){
			//目的地的首页
			return "m:destination";
		}else if ("toDestViews".equals(action)){
			//单独目的地的首页
			return "m:destination/"+destId;
		}else if ("viewDestTraffic".equals(action)){
			//目的地的交通
			return "m:destination/"+destId+"/traffic";
		}else if ("viewDestFeature".equals(action)){
			//目的地的特色
			return "m:destination/"+destId+"/"+inv.getParameter("featureId");
		}else if ("viewDestFeatureItem".equals(action)){
			//目的地的特色项
			return "m:destination/"+destId+"/item/"+inv.getParameter("featureItemId");
		}
		return "c:404";
	}
	
	/**
	 * 酒店精选:
	 *     首页:http://www.zentravel.cn/views/hotel/hotel.do?action=toOverviewHotel
	 *     目的地酒店:http://www.zentravel.cn/views/hotel/hotel.do?action=viewDestHotels&destId=27
	 *     酒店首页:http://www.zentravel.cn/views/hotel/hotel.do?action=viewHotelDetail&hotelId=18
	 *     房型:http://www.zentravel.cn/views/hotel/hotel.do?action=viewHotelResourceList&hotelId=18&resourceType=2&resourceId=754
	 *     酒店周边:http://www.zentravel.cn/views/hotel/hotel.do?action=viewHotelAround&hotelId=18
	 *     酒店周边的类别:http://www.zentravel.cn/views/hotel/hotel.do?action=viewHotelAround&hotelId=18&categoryId=10
	 *     酒店点评:http://www.zentravel.cn/views/hotel/hotel.do?action=viewHotelReview&hotelId=18&reviewId=18
	 */
	@Get("hotel/hotel.do")
	public String hotel(Invocation inv,@Param("action") String action,@Param("hotelId") int hotelId){
		if ("toOverviewHotel".equals(action)){
			//酒店的主页
			return "m:hotel";
		}else if ("viewDestHotels".equals(action)){
			//目的地的酒店
//			@Get("destination/{destId:[0-9]+}")
			return "m:hotel/destination/"+inv.getParameter("destId");
		}else if ("viewHotelDetail".equals(action)){
//			酒店首页:http://www.zentravel.cn/views/hotel/hotel.do?action=viewHotelDetail&hotelId=18
			return "m:hotel/"+hotelId;
		}else if ("viewHotelResourceList".equals(action)){
//			房型:http://www.zentravel.cn/views/hotel/hotel.do?action=viewHotelResourceList&hotelId=18&resourceType=2&resourceId=754
//			@Get("{hotelId:[0-9]+}/{type:[2|3|4]}")
			return "m:hotel/"+hotelId+"/"+inv.getParameter("resourceType")+"?rid="+inv.getParameter("resourceId");
		}else if ("viewHotelAround".equals(action)){
//			酒店周边:http://www.zentravel.cn/views/hotel/hotel.do?action=viewHotelAround&hotelId=18
//				 *     酒店周边的类别:http://www.zentravel.cn/views/hotel/hotel.do?action=viewHotelAround&hotelId=18&categoryId=10
		//@Get("{hotelId:[0-9]+}/around")
			return "m:hotel/"+hotelId+"/around?cid="+inv.getParameter("categoryId");
		}else if ("viewHotelReview".equals(action)){
//			酒店点评:http://www.zentravel.cn/views/hotel/hotel.do?action=viewHotelReview&hotelId=18&reviewId=18
			return "m:hotel/"+hotelId+"/review?rid="+inv.getParameter("reviewId");
		}
		return "c:404";
	}
	
	/**
	 * 关于我们:http://www.zentravel.cn/views/footer.do?action=about
	 * 隐私声明:http://www.zentravel.cn/views/footer.do?action=privacyStatement
	 * 网站声明:http://www.zentravel.cn/views/footer.do?action=networkStatement
	 * 官网指南:http://www.zentravel.cn/views/friend.do?action=friendInfo&id=3
	 */
	@Get({"footer.do","friend.do"})
	public String footer(@Param("action") String action,@Param("id") int id){
		if ("about".equals(action)){
			return "c:about";
		} else if ("privacyStatement".equals(action)){
			return "c:privacy";
		} else if ("networkStatement".equals(action)){
			return "c:website";
		} else if ("friendInfo".equals(action)){
			return "c:friend?id="+id;
		}
		return "c:404";
	}
}
